﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MusicWorks.Web.Logic.ShoppingService.svc;
using MusicWorks.Web.Logic.Views;
using WebFormsMvp;

namespace MusicWorks.Web.Logic.Presenters
{
    public class ViewBasketPresenter : Presenter<IViewBasketView>
    {
        
        public ViewBasketPresenter(IViewBasketView view) : base(view)
        {
            this.View.Load += View_Load;
        }

        void View_Load(object sender, EventArgs e)
        {
            var client = new ShoppingServiceClient();
            var basket = client.GetBasket("DefaultBasket");
            this.View.Model.LineItems = basket.LineItems;
            this.View.Model.Total = 0.00;
        }

        public override void ReleaseView()
        {
            this.View.Load -= View_Load;
        }
    }
}
